import 'dart:convert';

import 'package:flutter_test/flutter_test.dart';
import 'package:im_app/im/pojo/Enums.dart';
import 'package:im_app/im/service/LoginService.dart';
import 'package:im_app/im/socket/dto/business/Login.dart';
import 'package:im_app/im/socket/dto/business/SendData.dart';
import 'package:im_app/im/socket/service/RpcSendDataService.dart';
import 'package:logger/logger.dart';

import '../BaseImTest.dart';

void main() {
  test("test data change", () async {
    var imWebSocket = await BaseImTest.initWebSocket();
    var dataSource = await BaseImTest.initDb();
    var logger = Logger();

    LoginReq loginReq = LoginReq(userId: "曹操", password: "123456", machineCode: "demo",
        tenantCode: "0002", terminalType: "android");
    logger.i("login json: " + loginReq.toJson().toString());
    LoginService loginService = LoginService();
    LoginResp? loginResp = await loginService.login(loginReq, LoginType.password);
    logger.i("login success result : " + jsonEncode(loginResp));

    DataChangeReq dataChangeReq = new DataChangeReq(type: DataType.group,
        subType: DataSubType.g_ed_name, key: 'bca89072-8fbc-4b7f-9bfc-2b36b77220d2', value: 'demo!!!!');

    var rpcMessageService = RpcMessageService();
    var okResp = await rpcMessageService.sendDataChange(dataChangeReq);
    print("success ${okResp.localSeq}");

    dataSource.close();
  });
}